
var rootPath = getRootPath();

$(document).ready(function(){
	var userId = getQueryParamValue("userId");
	var vin = getQueryParamValue("vin");
	$("#userId").val(userId);
	$("#vin").val(vin);
	
	   var now = new Date();
	   var currYear = now.getFullYear();	
	   //选择日期
       $('#lastInsureDate').mobiscroll().date({
           theme: 'ios',
           lang: 'zh',
           display: 'bottom',
           mode: 'datetimeDate',
           max: new Date(now.getFullYear(), now.getMonth(), now.getDate()),
           dateFormat:'yyyy-mm-dd'

       });

	$('#modalCancel').click(function(){
				window.location.reload();
			});
	
	$('#modalSure').click(function(){
		 
		 var data={
				 tmCarOwnerUserId:"",
				 vin:"",
				 lastInsureDate:"",
			    }; 

		    	data.tmCarOwnerUserId = $.trim($("#userId").val()); 
		    	data.vin = $.trim($("#vin").val()); 
			    data.lastInsureDate = $.trim($("#lastInsureDate").val()); 
			    
			    
				$.ajax({
					type : 'POST',
					url : rootPath+'/wechat/api/potentialUsers/insuranceRecord',
					contentType:"application/json",
					data: JSON.stringify(data),
					error:function(XMLHttpRequest, ajaxOptions, thrownError){
						alert("失败");
					},
					success : function(data){
						window.location = rootPath + "/views/hp.html";
					}
				});
		 
	});
});